package com.xand.bt.terminal.ui.depth;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

import com.xand.bt.terminal.ui.UIConst;

public class MarketDepthTableDisplay {

	private JPanel jPanel;
	
	private MarketDepthTableModel model;
	
	private JTable jTable;
	
	private MarketDepthTableController tableController;
	
	private MarketDepthTableMouseListener listener;
	
	public MarketDepthTableDisplay() {
	
		this.model = new MarketDepthTableModel();
		this.tableController = new MarketDepthTableController(this.model);
		this.listener = new MarketDepthTableMouseListener();
		
		this.jTable = new JTable(this.model);
		this.jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		this.jTable.setFocusable(false);
		this.jTable.setCellSelectionEnabled(false);
		this.jTable.setBorder(UIConst.EMPTY_BORDER);
		this.jTable.getTableHeader().setReorderingAllowed(false);
		this.jTable.addMouseListener(listener);
		
		TableColumn col00 = jTable.getColumnModel().getColumn(0);
		col00.setPreferredWidth(100);
		
		TableColumn col01 = jTable.getColumnModel().getColumn(1);
		col01.setPreferredWidth(100);
		
		TableColumn col02 = jTable.getColumnModel().getColumn(2);
		col02.setPreferredWidth(100);
		
		TableColumn col03 = jTable.getColumnModel().getColumn(3);
		col03.setPreferredWidth(100);
		
		JScrollPane scrollPane = new JScrollPane(this.jTable);
		scrollPane.setPreferredSize(new Dimension(400, 350));
		scrollPane.setBorder(UIConst.EMPTY_BORDER);
		
		this.jPanel = new JPanel(new FlowLayout());
		this.jPanel.add(scrollPane);
		this.jPanel.setBorder(UIConst.MARKET_DEPTH_PANEL_BORDER);
		
	}
	
	public JPanel getPanel() {
		return this.jPanel;
	}
	
	public JTable getTable() {
		return this.jTable;
	}
	
	public MarketDepthTableModel getModel() {
		return this.model;
	}
	
	public MarketDepthTableController getController() {
		return this.tableController;
	}
	
}
